package com.codedancer.campus.client.api.captcha;

import com.codedancer.campus.client.service.ICaptchaService;
import com.codedancer.campus.client.service.vo.captcha.CaptchaVo;
import com.codedancer.campus.common.anno.PassToken;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/captcha")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "验证码Api", description = "验证码Api", tags = "验证码Api")
public class CaptchaApi extends BaseApi {

    @Autowired
    private ICaptchaService captchaService;

    @GetMapping("/generate")
    @ApiOperation("生成验证码")
    @PassToken
    public ApiResponse<CaptchaVo> generate(){
        return success(captchaService.generate());
    }
}
